import java.util.Arrays;

public class TwoDimensionalArrays {
    public static void main(String[] args) {
        //不规则的数组
        int[][] array1 = new int[2][];
        array1[0] = new int[3];
        array1[1] = new int[4];

        for (int i = 0; i < array1.length; i++) {
            for (int j = 0; j < array1[i].length; j++) {
                System.out.print(array1[i][j]+" ");
            }
            System.out.println();
        }
        System.out.println();
        for (int[] arr : array1) {
            for (int x : arr) {
                System.out.print(x+" ");
            }
            System.out.println();
        }
        System.out.println();

        System.out.println(Arrays.deepToString(array1));

    }
    public static void main4(String[] args) {
        int[][] array1 = new int[2][3];
        //通用打印方式，不用去查数组有几行几列
        //以下可证明二维数组是一种特殊的一维数组
        for (int i = 0; i < array1.length; i++) {
            for (int j = 0; j < array1[i].length; j++) {
                System.out.print(array1[i][j]+" ");
            }
            System.out.println();
        }
        System.out.println();

        for (int[] arr : array1) {
            for (int x : arr) {
                System.out.print(x+" ");
            }
            System.out.println();
        }

        System.out.println();

        System.out.println(Arrays.deepToString(array1));

    }
    public static void main3(String[] args) {
        int[][] array1 = new int[2][3];
        System.out.println(array1[0]);
        System.out.println(Arrays.toString(array1[0]));
        System.out.println(array1[1]);
        System.out.println(Arrays.toString(array1[1]));

    }
    public static void main1(String[] args) {
        //2行3列的
        //打印二维数组
        int[][] array1 = new int[2][3];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 3; j++) {
                System.out.print(array1[i][j]+" ");
            }
            System.out.println();
        }
        System.out.println();

        System.out.println(Arrays.deepToString(array1));

    }

    public static void main2(String[] args) {
        //二维数组的定义方式
        //Java里定义二维数组，必须指明哪些是一行的。
        int[][] array1 = new int[2][3];
        int[][] array2 = new int[][]{{1,2,3},{4,5,6}};
        int[][] arrays = {{1,2,3},{4,5,6}};

    }
}
